<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="80px">

      <el-form-item label="内网ip" prop="innerNetIp">
        <el-input
            v-model="queryParams.innerNetIp"
            placeholder="请输入设备内网ip"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="设备mac" prop="mac">
        <el-input
            v-model="queryParams.mac"
            placeholder="请输入设备mac"
            clearable
            size="small"
            @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
    </el-row>

    <el-table v-loading="loading" :data="nativedeviceList" >

      <el-table-column label="原生设备代号: esp32-wroom" align="center" prop="deviceCode" />
      <el-table-column label="设备内网ip" align="center" prop="innerNetIp" />
      <el-table-column label="设备mac" align="center" prop="mac" />
      <el-table-column label="" align="center" prop="lastUpdateTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.lastUpdateTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>

    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改设备入网记录对话框 -->

  </div>
</template>

<script>
  import { listNativedevice, getNativedevice, delNativedevice, addNativedevice, updateNativedevice, exportNativedevice } from "@/api/business/nativedevice";

  import {treeselect} from "@/api/selfcom/dept";
  import Treeselect from "@riophae/vue-treeselect";
  import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  import {MonthPicker} from '@/views/components/wowmonthpicker/src/index'

  export default {
  name: "Nativedevice",
  components: { Treeselect, MonthPicker },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 设备入网记录表格数据
      nativedeviceList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        creatorId: undefined,
        isDeleted: undefined,
        lastUpdateId: undefined,
        lastUpdateTime: undefined,
        deviceCode: undefined,
        innerNetIp: undefined,
        mac: undefined
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
    this.getTreeselect();
  },
  methods: {
    /** 查询设备入网记录列表 */
    getList() {
      this.loading = true;
      listNativedevice(this.queryParams).then(response => {
        this.nativedeviceList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 查询部门下拉树结构 */
    getTreeselect() {
      treeselect().then(response => {
        this.deptOptions = response.data;
      });
    },

    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        creatorId: undefined,
        isDeleted: undefined,
        lastUpdateId: undefined,
        lastUpdateTime: undefined,
        deviceCode: undefined,
        innerNetIp: undefined,
        mac: undefined
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

  }
};
</script>
